import { requestData } from '@/utils/request'

export default function getBaseApi(prefix) {
  return {
    add(data) {
      return requestData({
        url: `${prefix}/add`,
        method: 'post',
        data
      })
    },
    del(id) {
      return requestData({
        url: `${prefix}/del/${id}`,
        method: 'delete'
      })
    },
    list(params) {
      return requestData({
        url: `${prefix}/list`,
        method: 'get',
        params
      })
    },
    update(data) {
      return requestData({
        url: `${prefix}/update`,
        method: 'put',
        data
      })
    },
    get(id) {
      return requestData({
        url: `${prefix}/get/${id}`,
        method: 'get'
      })
    },
    detail(id) {
      return requestData({
        url: `${prefix}/detail`,
        method: 'get',
        params: { id }
      })
    }
  }
}
